Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Dates 1

Status
Not open for further replies.

maggielady

Technical User
Jan 3, 2003
60
US
I need to get a numeric date field into a string format yyyymmdd. EX> I have a field called joined that is numeric, field size is 8, I need it to be in a string format when the program runs. Thanks for any help you can give!!
 
Please provide more information about the field that has the dates kept in numeric format...is it the number of seconds since a particular date or what?


boyd.gif

craig1442@mchsi.com
"Whom computers would destroy, they must first drive mad." - Anon​
 
It's a numeric field populated like 72254. This is supposed to be a birth date of 07/22/54. The table I'm trying to put it into has a birth date field that has to have it in a string format yyyymmdd and be character type. Thanks
 
Juris
That would be November 1st 75. I see what you mean. I'll have to rework that data. Thanks for all your help!!
 
This help, I hope... with dual talking about 111 mentioned above


Code:
lcDateSettings=Set([DATE])
Set Date German

lnInteger=72254
lcInteger=Alltrim(Str(lnInteger))
lcYear=Right(lcInteger,2)
lcYear=Iif(Val(lcYear)<=Year(Date())-2000,"20","19")+lcYear
lcDayMonth=Left(lcInteger,Len(lcInteger)-2)
Do Case
   Case Len(lcDayMonth)=4
      lcMonth=Left(lcDayMonth,2)
      lcDay=Right(lcDayMonth,2)
      ? lcMonth
      ? lcDay
   Case Len(lcDayMonth)=3
      lcTest=Left(lcDayMonth,1)

      If lcTest="1"

      && January 11th or November 1st ??
      Else
         lcMonth=Left(lcDayMonth,1)
         lcDay=Right(lcDayMonth,2)
      Endif
   OTHERWISE  && 2 digits
      lcMonth=Left(lcDayMonth,1)
      lcDay=Right(lcDayMonth,1)
Endcase
ldDate=Ctod(lcDay+[.]+lcMonth+[.]+lcYear)
? ldDate
Set Date &lcDateSettings
? DTOS(ldDate)

Good luck!

Juri Shutenko
Municipality of Maardu, Estonia
 
Hi maggielady
Try this
TRANSFORM((YEAR(ldate)),"@L 9999")+TRANSFORM(MONTH(ldate),"@L 99")+TRANSFORM(DAY(ldate),"@L 99")

The format "@L 99" forces zeros ie a date 1st feb 2004 will display: 20040201
the good thing with this is it is internantional ie strange USA dates still work ;)
if you only want yy try TRANSFORM((YEAR(ldate)-2000),"@ 99)
regards
Andrew
ha first post!!
 
? ALLTRIM(STR(YEAR(DATE()))) + PADL(ALLTRIM(STR(MONTH(DATE()))),2,"0") + PADL(ALLTRIM(STR(DAY(DATE()))),2,"0")


* Here are the pieces individually.
* Year
? ALLTRIM(STR(YEAR(DATE())))

* Month
? PADL(ALLTRIM(STR(MONTH(DATE()))),2,"0")

* Day
? PADL(ALLTRIM(STR(DAY(DATE()))),2,"0")

Jim Osieczonek
Delta Business Group, LLC
 
Stefan5627

Old habits are hard to break. Your solutions is certainly easier than mine.

A
star.gif
for U.

Jim Osieczonek
Delta Business Group, LLC
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top