Solved

Formating Date

Posted on 2003-11-26
8
242 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Easy, flexible multimedia distribution & control

Coming soon!  Ideal for large-scale A/V applications, ATEN's VM3200 Modular Matrix Switch is an all-in-one solution that simplifies video wall integration. Easily customize display layouts to see what you want, how you want it in 4k.

 
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

Forrester Webinar: xMatters Delivers 261% ROI

Guest speaker Dean Davison, Forrester Principal Consultant, explains how a Fortune 500 communication company using xMatters found these results: Achieved a 261% ROI, Experienced $753,280 in net present value benefits over 3 years and Reduced MTTR by 91% for tier 1 incidents.

Question has a verified solution.

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

In our day to day coding, how many times have we come across a necessity to check whether a URL is a broken link or not? For those of you that answered countless and are using ColdFusion like myself, then this article is for you.  It will show yo…
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…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

752 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