Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Date/time functions in SQL Server 2005

Date/time functions in SQL Server 2005

Scheduled Pinned Locked Moved Database
databasesql-serversysadminhelptutorial
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    PrashantJ
    wrote on last edited by
    #1

    Hi All, I am looking for the functions in SQL server which would return me the mid day, last day of the month given the current date and the param. I would appreciate if you could point me to some related links. I have written some SQLs to do this but looks very ugly with lots of code. Input will be some date and period. Output will be the Till ending date interval1 and Till ending date interval2 If period(1) = weekly then the Till ending date = end of the current week (Sun) - I assume a week begins on Monday. If period(2) = bi-weekly then the Till ending date = end of the following week (Sun) If period(3) = semi-monthly & today <= 15th of the month then the Till ending date = 15th of the current month, otherwise Till ending date = end of month. If period(4) = monthly then the Till ending date = end of month For example: Input Some_date : 1-Jan-2006 Period Output Period Out1 Out2 1 8-Jan 15-Jan 2 15-Jan 29-Jan 3 15-Jan 31-Jan 4 31-Jan 28-Feb Thanks for the help.

    S 1 Reply Last reply
    0
    • P PrashantJ

      Hi All, I am looking for the functions in SQL server which would return me the mid day, last day of the month given the current date and the param. I would appreciate if you could point me to some related links. I have written some SQLs to do this but looks very ugly with lots of code. Input will be some date and period. Output will be the Till ending date interval1 and Till ending date interval2 If period(1) = weekly then the Till ending date = end of the current week (Sun) - I assume a week begins on Monday. If period(2) = bi-weekly then the Till ending date = end of the following week (Sun) If period(3) = semi-monthly & today <= 15th of the month then the Till ending date = 15th of the current month, otherwise Till ending date = end of month. If period(4) = monthly then the Till ending date = end of month For example: Input Some_date : 1-Jan-2006 Period Output Period Out1 Out2 1 8-Jan 15-Jan 2 15-Jan 29-Jan 3 15-Jan 31-Jan 4 31-Jan 28-Feb Thanks for the help.

      S Offline
      S Offline
      Scott Holt
      wrote on last edited by
      #2

      Do you have SQL Server Help? Start by looking at the help for functions GETDATE() and DATEPART(). Then follow other related links from there. Scott

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups