VBdotnet2005
asked on
Date convertion
How can I convert this date format to YYYYMMDD?
2013-04-02 00:00:00.000
to
YYYYMMDD
20130402
2013-04-02 00:00:00.000
to
YYYYMMDD
20130402
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Declare @dt datetime = '2013-04-02 00:00:00.000'
SELECT CONVERT(char(8), @dt, 112)
Or perhaps you're expecting a number? Then:
Declare @dt datetime = '2013-04-02 00:00:00.000'
SELECT CONVERT(int, CONVERT(char(8), @dt, 112))