Date reformat question for the group
- From: Graham (Pete) Berry <PeteBerry@xxxxxxxxxxx>
- Date: Tue, 15 May 2007 10:42:44 -0700
I hope I am posting this in the correct group, but if not please tell me
the proper place. I am more of an admin type than a developer and am
having a problem I have been unable to code around. In short, what I
want to do is convert today's date and time into a series of local
numerical character variables
YYYY
MM (with a leading 0 if LT 10)
DD (with a leading 0 if LT 10)
HH (24-hour format)
SS
This format is equivalent to a CONVERT function style code of 120 with
the separators removed.
Tried various combinations of SUBSTRING and CONVERT functions, but they
did not work. For example the SUBSTRING can only handle CHAR/VARCHAR
type data. Then the GETDATE() function represents the internal DATETIME
format as
MMM DD YYYY HH:MMAM or
MMM DD YYYY HH:MMPM
where the leading D=0 and H=0 are omitted. The YEAR and DAY functions
work but also omit any leading zero's and there is no corresponding
HOURS or MINUTES function
Any coders out there with a suggested solution as to how I can do this?
I've run out of ideas and BOL hasn't helped.
--
Graham (Pete) Berry
PeteBerry@xxxxxxxxxxx
.
- Prev by Date: Re: using wildcards [ ] in REPLACE or CHARINDEX functions
- Next by Date: Re: Get user syntax
- Previous by thread: Re: using wildcards [ ] in REPLACE or CHARINDEX functions
- Next by thread: Re: Get user syntax
- Index(es):