borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder

AndreaVB | Forum | News | Downloads | Register | Help | Member List | Statistics | Search | PM | Profile

Print This Topic
Previous Topic (MS Access Compact & Repair database option)Next Topic (sql query in VB Direct code) New Topic New Poll Post Reply
AndreaVB Forum : Database : MSHFlexGrid Date Format ...
Poster Message
sneha
Level: Scholar

Registered: 28-03-2006
Posts: 29

icon MSHFlexGrid Date Format ...

Hi,

How can I change the date format mm/dd/yyyy to dd/mm/yyyy in MSHFlexGrid?

Regards,

Sneha

____________________________
Sneha

22-07-2006 at 07:53 AM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: MSHFlexGrid Date Format ...

Hi Sneha,
Try:-

   Dim strToday as String

   strToday = Format$(Date, "dd/mm/yyyy")
   MSHFlexGrid1.Col =2
   MSHFlexGrid1.Row =2
   MSHFlexGrid1.Text = strToday

:OK



____________________________
multi-tasking - the ability to hang more than one app. at the same time.

23-07-2006 at 11:45 AM
View Profile Send Email to User Show All Posts | Quote Reply
sneha
Level: Scholar

Registered: 28-03-2006
Posts: 29
icon Re: MSHFlexGrid Date Format ...

quote:
GeoffS wrote:
Hi Sneha,
Try:-

   Dim strToday as String

   strToday = Format$(Date, "dd/mm/yyyy")
   MSHFlexGrid1.Col =2
   MSHFlexGrid1.Row =2
   MSHFlexGrid1.Text = strToday

:OK





Thanks a lot for your help. Actually I need to view the date in the following format but not to change it in the database:

dd/mm/yyyy

Could you please help me in this regard? I am using MS Access database "Sales.mdb", Table name is "Collections" & field name is "DepositDate"

I need to view the complete column/field in the above format.

Regards,

Sneha.

[Edited by sneha on 23-07-2006 at 08:54 PM GMT]

[Edited by sneha on 23-07-2006 at 08:57 PM GMT]

____________________________
Sneha

____________________________
Attached:
DateFormat.jpg (16 KB)
23-07-2006 at 12:44 PM
View Profile Send Email to User Show All Posts | Quote Reply
GeoffS
Level: VB Lord


Registered: 29-09-2004
Posts: 536
icon Re: MSHFlexGrid Date Format ...

Hi Sneha,

Access will always display the date according to your localisation, so if your locale is set as U.S. then it will store and display dates in the mm/dd/yyyy format, which means that if you supply a U.K. formatted date (dd/mm/yyyy) to the database, and it can represent a valid U.S. formatted date, such as 1st. May 2006  as 01/05/2006 then the date may well get changed to 5th. Januuary 2006. When you bind the MSHFlexgrid directly to data then it will display that data in the format in which it is retrieved. As far as I am aware you cannot set a column property of the control to force a particular date format, you will have to retrieve the data into memory and then allocate it to each cell, applying the formatting as I described above.
If you are having problems with dates it is worth bearing in mind that the underlying data type that Access actually uses to store the date is a numeric data type - a Double - where the whole number represents the number of days elapsed since 30th. December 1899 and the decimal part represents the time. So you could convert your dates to a Long (get rid of the decimal otherwise you will never get a date = date because the time portion will be different) and store it that way. Then you can get it to display in any way that you want by simply formatting the text box or whatever control you display it in.
Dates are a problem for a lot of us - take a look at this previous thread which may cast a bit more light for you:-
http://www.andreavb.com/forum/viewtopic.php?TopicID=6501&page=0#21959



____________________________
multi-tasking - the ability to hang more than one app. at the same time.

23-07-2006 at 02:36 PM
View Profile Send Email to User Show All Posts | Quote Reply
AndreaVB Forum : Database : MSHFlexGrid Date Format ...
Previous Topic (MS Access Compact & Repair database option)Next Topic (sql query in VB Direct code) New Topic New Poll Post Reply
Surf To:


Not Logged In? Username: Password: Lost your password?
Partners: Download Actual Software | Free Software Download
borderAndreaVB free resources for Visual Basic developersborder

borderAndreaVB Visual Basic and VB.NET source code resources - Copyright © 1999-2007 Andrea Tincaniborder