Date Format Help Needed (Full Version)

All Forums >> [Web Development] >> ASP and Database



Message


mmoore0319 -> Date Format Help Needed (4/25/2008 14:45:06)

Hello,

How can I take a general number field and convert it to date format mm/dd/yy?

Example data that is pulled from csv file into database is 42108.

The current command used, <%=FP_FieldVal(fp_rs,"InvoiceDate")%>, produces the same output but I want it in the above mentioned format.

Using <%=FormatDateTime(FP_FieldVal(fp_rs,"InvoiceDate")%> converts the date into some odd date not even close to the original.

Any help would be appreciated.

Thanks!




rdouglass -> RE: Date Format Help Needed (4/25/2008 15:16:12)

quote:

<%=FormatDateTime(FP_FieldVal(fp_rs,"InvoiceDate")%>


Did you try this way:

<%=FormatDateTime(FP_Field(fp_rs,"InvoiceDate"),VBShortDate)%>

That any better?




rdouglass -> RE: Date Format Help Needed (4/25/2008 15:17:45)

quote:

Example data that is pulled from csv file into database is 42108


Ooops. Pulling fro a CSV, eh? Are you sure it's being recognized as a date and not a number? If it were being considered a number by the DRW, then yes it would be a very strange date.




mmoore0319 -> RE: Date Format Help Needed (4/25/2008 15:22:36)

I believe it is being recognized as a number and not a date. I have tried changing the Access column format from Number to Date/Time however, it also produces the same odd dates. I am not sure how I can correct the data in the Access database so was hoping for some insight into addressing the formatting from the webpage side of it. Of course, I would welcome a solution from the Access side as well.




Spooky -> RE: Date Format Help Needed (4/25/2008 16:53:37)

It would need to be formatted correctly when first inserted into the access database.
Im not too sure how you have that part working yet.

However, ignoring that fact and using it as a plain number, you would probably need to use VB to split out the parts you need. The problem lays in the fact you dont pad the month / date with the leading "0"

eg 11508 gives 2 options x/xx/xx or xx/x/xx
The real date needs to be 011508 so that you can easily split into 2/2/2 (or xx/xx/xx)

It may be hard to define easily which is the month and date, especially when 11508 or 11508 may be valid values




mmoore0319 -> RE: Date Format Help Needed (4/25/2008 17:38:47)

I'm not sure how I could do this since it is a csv file from a data dump out of AS400.

What I am doing is taking the data and importing it into an Access table. At this point, I tried to format the column as a Date but this did not help since it converted it into meaningless dates.

Yes, I understand your point. Is it possible to work backwards by taking 42008 and having the last two digits represent yy, the middle two as dd, and whatever is left over be mm?

thanks,




Spooky -> RE: Date Format Help Needed (4/25/2008 19:25:07)

Im thinking not easily, as the middle 2 may not represent the date.
If there are 6 digits or 4 digits, then its real easy. Its when there are 5 the problems arise.

eg does 121 represent the 21st of Jan or the 1st of Dec? Your data will be out by 11 months.
It depends how important this is to you as both Nov and Dec would be effected




rdouglass -> RE: Date Format Help Needed (4/28/2008 11:41:38)

quote:

csv file from a data dump out of AS400.


Just a thought.

Do you have any influence on how that comes out? See, if you could get that to be formatted MMDDYYYY (or any other date-distinguishable format) when the export is done, then it's pretty straightforward.

</$.02>




Page: [1]

Valid CSS!




Forum Software © ASPPlayground.NET Advanced Edition 2.4.5 ANSI
0.046875