meteorelec
asked on
SQL- Start of month date function
i am currently using this to get the start of the day,
CAST(FLOOR(CAST(GETDATE() AS FLOAT))AS DATETIME)
what would i use to get the start of the month, also could you explain what the expression means, thank you
CAST(FLOOR(CAST(GETDATE() AS FLOAT))AS DATETIME)
what would i use to get the start of the month, also could you explain what the expression means, thank you
Hello meteorelec,
To get today, I like this better:
CONVERT(datetime, CONVERT(varchar, GETDATE(), 101))
1st of month:
CONVERT(datetime, CONVERT(varchar, DATEADD(d, 1 - DAY(GETDATE())), 101)
Regards,
Patrick
To get today, I like this better:
CONVERT(datetime, CONVERT(varchar, GETDATE(), 101))
1st of month:
CONVERT(datetime, CONVERT(varchar, DATEADD(d, 1 - DAY(GETDATE())), 101)
Regards,
Patrick
ASKER
Hi Patrick,
CONVERT(datetime, CONVERT(varchar, DATEADD(d, 1 - DAY(GETDATE())), 101)
is give me back
The dateadd function requires 3 argument(s)
CONVERT(datetime, CONVERT(varchar, DATEADD(d, 1 - DAY(GETDATE())), 101)
is give me back
The dateadd function requires 3 argument(s)
Sorry!
CONVERT(datetime, CONVERT(varchar, DATEADD(d, 1 - DAY(GETDATE()), GETDATE()), 101)
CONVERT(datetime, CONVERT(varchar, DATEADD(d, 1 - DAY(GETDATE()), GETDATE()), 101)
ASKER
Incorrect syntax near ')'.
is what i'm getting now
is what i'm getting now
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Open in new window