4 Replies - 2952 Views - Last Post: 25 September 2012 - 06:33 AM Rate Topic: -----

#1 hwkong1688  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-September 11

how to set the date dd/MM/yyyy in correct way?

Posted 21 September 2012 - 09:23 PM

Hi,
when regional setting set to dd/MM/yyyy the date i pickup is not
collectly, if regional setting set to MM/dd/yyyy then all
is fine? how to set the date dd/MM/yyyy in correct way?

database: access
dt = date/time

my code here
Private Sub Form_Load()

DTPicker2 = Date
DTPicker3 = Date

End Sub



Private Sub ViewReport_Click()
On Error GoTo 0

If MsgBox("          View Report?", vbYesNo, "View Report") = vbYes Then
DataReport1.Orientation = rptOrientLandscape

DataEnvironment1.Commands(1).CommandText = "Select * From Daily Where Dt Between #" & DTPicker2 & "# and #" & DTPicker3 & "# Order by Dt"
DataReport1.Show
End If

Load DataEnvironment1
With DataEnvironment1
If .rsCommand1.State <> 0 Then .rsCommand1.Close
.Command1
End With

End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: how to set the date dd/MM/yyyy in correct way?

#2 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: how to set the date dd/MM/yyyy in correct way?

Posted 21 September 2012 - 10:11 PM

use the format function to format the date that will solve your problem
like this
"Select * From Daily Where Dt Between #" & Format(DTPicker2 ,"MM/dd/YYYY") & "# and #" & Format(DTPicker3 ,"MM/dd/YYYY") & "# Order by 


Was This Post Helpful? 1
  • +
  • -

#3 hwkong1688  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 36
  • Joined: 30-September 11

Re: how to set the date dd/MM/yyyy in correct way?

Posted 22 September 2012 - 12:36 AM

thank you so much thava..it work!!..but i want to know why i use format(DTpicker2 "dd/MM/yyyy") doesn't work??
Was This Post Helpful? 0
  • +
  • -

#4 thava  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 180
  • View blog
  • Posts: 1,606
  • Joined: 17-April 07

Re: how to set the date dd/MM/yyyy in correct way?

Posted 23 September 2012 - 09:35 PM

sorry buddy it's my mistake
Format is a function to format the output as you want


Following links will help you learn about the function
Understanding the VB Format Function with Custom Numeric Formats

Formating dates and times in VB6
Was This Post Helpful? 0
  • +
  • -

#5 BobRodes  Icon User is offline

  • Your Friendly Local Curmudgeon
  • member icon

Reputation: 572
  • View blog
  • Posts: 2,985
  • Joined: 19-May 09

Re: how to set the date dd/MM/yyyy in correct way?

Posted 25 September 2012 - 06:33 AM

Probably because you have your culture settings set up as USA, and your data are being input in a European format. You'll also want to investigate culture settings and how they work in Windows.

This post has been edited by BobRodes: 25 September 2012 - 06:33 AM

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1