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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Formating dates 1

Status
Not open for further replies.

Cheech

Technical User
Nov 6, 2000
2,933
EU
I have got a problem with date format on an Intranet. I need to be able to display the date in the UK format (dd/mm/yy) after using Date() & DateAdd() it works fine on my development server but after uploading to the live one all sorts of funnies happen. The date is displayed as mm/dd/yy from Date() but as yy/mm/dd after DateAdd().....AHHHHGGGGG

HELP(failing that anyone kow of a quick script that will grab the date and reformat it into dd/mm/yy sequence.

As always guys Cheers for any help in advance. T.C. I dont want to go to Chelsea!!!
 

Hi,

Use the split function with a delimiter of "/" to transpose dd and mm. Should be pretty easy.

Dim Qarray
strDate = "31/05/01"
Qarray = split(strDate, "/", -1)
dd = Qarray(0)
mm = Qarray(1)
yy = Qarray(2)

Fengshui_1998
 
I use these functions. Very handy.


'Convert American date to Australian Date for viewing
Function CAmericanDate(curval)
dtDay = ""
dtMonth = ""

If curval <> &quot;&quot; then

If isdate(curval) = true then
If Day(curval) < 10 Then
dtDay = &quot;0&quot;
End If

If Month(curval) < 10 then
dtMonth = &quot;0&quot;
End If

CAmericanDate = dtDay & Day(curval) & &quot;/&quot; & dtMonth & Month(curval) & &quot;/&quot; & Year(curval)
End If
End If
End Function


'Convert Australian Date to American Date for Data input
Function CAustDate(tFieldValue)

If tfieldvalue <> &quot;&quot; then

dtDaySep = InStr(1, tFieldValue, &quot;/&quot;)
dtDay = Left(tFieldValue, dtDaySep - 1)
dtMonthSep = InStr(dtDaySep + 1, tFieldValue, &quot;/&quot;)
dtMonth = Mid(tFieldValue, dtDaySep + 1, dtMonthSep - (dtDaySep + 1))
dtYear = Mid(tFieldValue, dtMonthSep + 1, len(tFieldValue))
CAustDate = dtmonth & &quot;/&quot; & dtDay & &quot;/&quot; & dtYear
End If

End Function
 
Thnks Guys the first function from Fengshui_1998 works well and also allows me to reformat it quickly if the Server set up should be changed.

Cheers I dont want to go to Chelsea!!!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top