Solved

Formating Date

Posted on 2003-11-26
8
241 Views
Last Modified: 2013-12-24
I am using a (MS Access) database  to store credit card expired date as 06/04. When I type expired date in text field (Example: 06/04) it stores date in Access as 7/12/1894. What is the syntax storing date as 06/04 or 06/2000 using CF.

Thanks, Angela
0
Comment
Question by:Angela030399
  • 4
  • 3
8 Comments
 
LVL 12

Expert Comment

by:jyokum
ID: 9826471
how are you inserting it into access, what's your query look like?
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9826832
it's not the insert it's access

don't use the date time datatype for the field use text and strore the date as 06/04

and use cf to format it on output if neccessry
0
 
LVL 12

Expert Comment

by:jyokum
ID: 9826910
Jester_48,
why not use a date field? 06/04 is just assumed to be 06/01/04 00:00:00. doing it this way make it real easy to do date math against this field... things like quering all the accounts whose credit card expires in the next 60 days.
0
Portable, direct connect server access

The ATEN CV211 connects a laptop directly to any server allowing you instant access to perform data maintenance and local operations, for quick troubleshooting, updating, service and repair.

 
LVL 25

Expert Comment

by:James Rodgers
ID: 9827220
>>why not use a date field? 06/04 is just assumed to be 06/01/04 00:00:00

not always, access can be strange when interacting with certain datatypes like date/time, the program sometimes makes assumptions about what the data you are trying to enter *should* be

open an access database and create a new table with a field using date time, set the format to anything, access always tries to convert the input to a usable format which can have some strange results, so if you input a two part date such as 06/04 you can get the following results, depending on which format you have set, such as

7/12/1894
06/03
06/04/2004

noe of which is even close to what you need
but if you format the date before entering, what do you use as the 'day' of the date? the first day of the month, then on june second your card would be denied, end of the month, then you need a formula to calculate the last day of the month before inserting

if you store the two part date as text then you will always have it in the appropriate cc format
0
 
LVL 12

Expert Comment

by:jyokum
ID: 9827246
which is exactly why I asked the question "how are you inserting it into access, what's your query look like? "
0
 
LVL 25

Expert Comment

by:James Rodgers
ID: 9827320
i am not questioning your request, merely stating some of the peculiarities of access will affect the process of storing a 2 part date as opposed to a regular date
0
 
LVL 17

Accepted Solution

by:
anandkp earned 500 total points
ID: 9829569
try & do this

<CFSET USERDATE = "06/04">
<CFSET USERDATE = CreateDate(year(now()),'06','04')><!--- Converting it to a properdate format Year / Month / Day --->

<CFQUERY NAME="Ins_DateInAccess" DATASOURCE="Dsn">
    Insert into table (name,mydate_field)
      values
      (<CFQUERYPARAM CFSQLTYPE="cf_sql_varchar" VALUE="anandkp">,
      <CFQUERYPARAM CFSQLTYPE="cf_sql_date" VALUE="#UserDate#">)
</CFQUERY>

Now with a properdate in ur database - like jyokum said "doing it this way makes it real easy to do date math against this field... things like quering all the accounts whose credit card expires in the next 60 days"

HTH

K'Rgds
Anand

PS : I wld not advice on storing dates as plain text in formats "06/04 or 06/2000" - dosent help the cause !
0
 
LVL 12

Expert Comment

by:jyokum
ID: 10049748
Angela,
This has been open 40 days and there hasn't been a comment added in 40 days.
Please select a comment as the solution or give us an update.

jyokum
0

Featured Post

Active Directory Webinar

We all know we need to protect and secure our privileges, but where to start? Join Experts Exchange and ManageEngine on Tuesday, April 11, 2017 10:00 AM PDT to learn how to track and secure privileged users in Active Directory.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever sent email via ColdFusion and thought of tracking this mail to capture the exact date and time when the message was opened ?  If yes, then this article is for you ! First we need a table user_email with columns user_id , email , sub…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

821 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question