|
-
Aug 31st, 2006, 04:14 PM
#1
Thread Starter
Hyperactive Member
[RESOLVED] Local Date to DOS Date
Hi does anyone now how I can say take a Date and Time such as 10/2/2006 10:10:00 AM and encoded it to the standard MS DOS format.
The reason I need this is because I am working on some small compression program and the date for PKZip compatable files.
I looked in the forums, code bank and the internet and Cannot seem to find anything what so ever.
any help or code examples will be greatfull.
Thanks
When your dreams come true.
On error resume pulling hair out.
-
Aug 31st, 2006, 04:24 PM
#2
Re: Local Date to DOS Date
What is the standard MS DOS format for date and time?
-
Aug 31st, 2006, 04:34 PM
#3
Re: Local Date to DOS Date
VB Code:
Option Explicit
'Dos Format: Fri 01/09/2006
Private Sub Form_Load()
MsgBox Dos_Date_Format(#10/2/2006 10:10:00 AM#)
MsgBox Dos_Date_Format(Now)
End Sub
Private Function Dos_Date_Format(dteDate As Date) As String
Dim strDay As String
'Determin the day, and truncate it to 3 letters
strDay = Left$(WeekdayName(Weekday(dteDate, vbMonday)), 3)
'Join the truncated day and the date
Dos_Date_Format = strDay & " " & Format$(dteDate, "mm/dd/yyyy", vbMonday)
End Function
Last edited by Bruce Fox; Aug 31st, 2006 at 04:40 PM.
-
Aug 31st, 2006, 04:35 PM
#4
Thread Starter
Hyperactive Member
Re: Local Date to DOS Date
well from what information I did find with was not very much it just talks about how it packed and then stored as a Long Int value. tho I duno how to pack it that what I need to figure out.
When your dreams come true.
On error resume pulling hair out.
-
Aug 31st, 2006, 04:39 PM
#5
Re: Local Date to DOS Date
I assumed that you required the format that is presented when you enter "Date" in the command promt.
-
Aug 31st, 2006, 04:46 PM
#6
Thread Starter
Hyperactive Member
Re: Local Date to DOS Date
No I need the long value returned form a local date but thanks for the code anyway might be usfull for something else
Below I left the code that will unpack the long Date and Time value what I need to know is how to put pack the date and time to make a long value
Code:
Private Function SHR(iByte As Long, iShift As Long) As Long
'Shift right
SHR = (iByte \ (2 ^ iShift))
End Function
Private Sub Command1_Click()
Dim DateTimeVal As Long
Dim iDate As Date
Dim iTime As Date
DateTimeVal = 752685168 'This long value has date and time
'Last Update Date
iDate = DateSerial((SHR(DateTimeVal, 25) And &H7F) + 1980, _
(SHR(DateTimeVal, 21) And &HF), _
SHR(DateTimeVal, 16) And &H1F)
'Last Update Time
iTime = TimeSerial((SHR(DateTimeVal, 11) And &H1F), _
(SHR(DateTimeVal, 5) And &H3F), _
SHR(DateTimeVal, 16) And &H1F)
MsgBox iDate & "--" & iTime
End Sub
Last edited by dreamvb; Aug 31st, 2006 at 06:10 PM.
When your dreams come true.
On error resume pulling hair out.
-
Sep 1st, 2006, 09:25 AM
#7
Thread Starter
Hyperactive Member
Re: Local Date to DOS Date
Has anyone else got some ideas that may help. I tryed looking on the net agian and still can;t seem to find much of anything. I know you guys are busy with your own projects but I really need to sort this out.
Thanks.
Last edited by dreamvb; Sep 1st, 2006 at 10:10 AM.
When your dreams come true.
On error resume pulling hair out.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|