|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
"dd/mm/yyyy" not "mm/dd/yyyy" !!!!!!
I have this:
Code:
<cfquery name="getdate" datasource="datasource"> SELECT EventDate FROM Events WHERE EventTitle = '#title#' </cfquery> With which I do this: Code:
<cfset date = dateformat(getdate.EventDate,"dd/mm/yyyy")> And so #date# will read 9/8/2005 for example. Which translates as 9th August 2005 (dd/mm/yyyy). Fine. When I go to take that variable #date# and stick it in the database (the collumn is datetime) it ALWAYS goes in as mm/dd/yyyy no matter what I seem to do. I have tried this: Code:
<cfquery name="add_details" datasource="HMCEOnline">
INSERT
INTO reg_interest ("emailadd","eventname","eventdate")
VALUES ('#email#','#title#', '#DateFormat(CreateODBCDateTime(getdate.EventDate), "dd/mm/yyyy")#')
</cfquery>
As well as just '#date#' which I figured would transfer it as text. Any ideas??? |
|
#2
|
|||
|
|||
|
A date field in a database has a specific format that actually looks nothing like '9/8/05'. Is this a date data type in the database? If so you will need to format the date the way you would like to when you perform a query.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums Last edited by kiteless : August 10th, 2005 at 08:02 AM. |
|
#3
|
|||
|
|||
|
I just need some clarification on that. Not 100% with you.
The data type is a datetime, yes. When you say: "you will need to format the date the way you would like to when you perform a query" What do you mean exactly? because i do format the date once it's been fetched from the DB (see: cfset date = bla bla) And it goes in fairly ok as mm/dd/yyyy but should be dd/mm/ Could you just clearify at all? Many thanks |
|
#4
|
|||
|
|||
|
That's the thing, YOU think it's going in like '9/8/05' or '8/9/05' or whatever, but a date/time value is actually stored in a very specific way in the database (which varies from vendor to vendor). But the point is, there is no way to tell the database to save a date in a date/time field with a specific "format"...there is no format as far as the database is concerned.
|
|
#5
|
|||
|
|||
|
bingo.
I just had it go in straight, without any formatting, from SELECT result to INSERT, i let it go in unformatted and that did the trick. many thanks, you've been a great help ![]() |
|
#6
|
|||
|
|||
|
Happy to help! Yep, it just means you need to do any formatting when you pull the data out (preferrably in the SQL statement itself using whatever date formatting or string formatting functions your database has available).
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > "dd/mm/yyyy" not "mm/dd/yyyy" !!!!!! |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|