0
Converting string to Date
LEGEND
,
/t5/coldfusion-discussions/converting-string-to-date/td-p/330998
Apr 21, 2008
Apr 21, 2008
Copy link to clipboard
Copied
Can coldfusion convert the following date string query
variable i have
20080418 to a formatted date.
eg; 15-Apr-2008
Or does my string have to be something like 20008/04/18 or 2008-04-18
This dosent work below, I dont have the quotes in the right places I think.
Thanks
B
#dateformat("query.orderdate", "d-mmm-yyyy")#
20080418 to a formatted date.
eg; 15-Apr-2008
Or does my string have to be something like 20008/04/18 or 2008-04-18
This dosent work below, I dont have the quotes in the right places I think.
Thanks
B
#dateformat("query.orderdate", "d-mmm-yyyy")#
TOPICS
Advanced techniques
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
LEGEND
,
/t5/coldfusion-discussions/converting-string-to-date/m-p/330999#M29934
Apr 21, 2008
Apr 21, 2008
Copy link to clipboard
Copied
The best answer is to store dates as dates instead of
strings.
But, if you must use strings, look at these cold fusion functions, left, mid, right, and createdate
But, if you must use strings, look at these cold fusion functions, left, mid, right, and createdate
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Advisor
,
/t5/coldfusion-discussions/converting-string-to-date/m-p/331000#M29935
Apr 21, 2008
Apr 21, 2008
Copy link to clipboard
Copied
Try removing the quotes from around query.orderdate.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more
Valorous Hero
,
LATEST
/t5/coldfusion-discussions/converting-string-to-date/m-p/331001#M29936
Apr 21, 2008
Apr 21, 2008
Copy link to clipboard
Copied
bj wrote:
No. DateFormat expects a "date" object and returns a string. Since 20080418 is not a date object ColdFusion treats it as a numeric representation of a date. Not as 2008-04-18 (ie April 18, 2008).
AFAIK, your options are those Dan Bracuk suggested. Either store the values as "dates" or use functions to convert your string into a "date" object first. Then use DateFormat.
quote:
Can coldfusion convert the following date string query variable i have 20080418 to a formatted date.
eg; 15-Apr-2008
No. DateFormat expects a "date" object and returns a string. Since 20080418 is not a date object ColdFusion treats it as a numeric representation of a date. Not as 2008-04-18 (ie April 18, 2008).
AFAIK, your options are those Dan Bracuk suggested. Either store the values as "dates" or use functions to convert your string into a "date" object first. Then use DateFormat.
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting.
Learn more

