Solved

Formating Date

Posted on 2003-11-26
8
236 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
 
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
Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

 
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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Most ColdFusion developers get confused between the CFSet, Duplicate, and Structcopy methods of copying a Structure, especially which one to use when. This Article will explain the differences in the approaches with examples; therefore, after readin…
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

705 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now