|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
SlickEdit: Code in over 40 languages across 7 platforms. SlickEdit’s unmatched power, speed, and flexibility allows even the most accomplished developers to write better code faster. Download a free trial today! |
|
#1
|
|||
|
|||
|
Date format and datediff problem..
Hi,
I am having some problems.. automating datediff function in VB 6.0, since I have two columns with dates (equal number of rows ) and wish to find the difference in each row.. with respect to the number of days.. Currently this is what I have implemented as simple logic: Code:
'Dim date1 As String
'Dim date2 As String
'Dim currdate As Variant
'Dim startdate As String
'Dim diffdate As String
'date1 = "05.02.2006"
'currdate = Split("" & date1 & "", ".")
'startdate = "" & currdate(2) & "-" & currdate(1) & "-" & currdate(0) & ""
'date2 = "2006-11-25"
'diffdate = DateDiff("d", "" & startdate & "", "" & date2 & "")
'Debug.Print diffdate
My dates in the two columns have the format: Code:
Date1 Date2 06.01.2006 06.02.2006 06.01.2006 06.02.2006 06.01.2006 01.02.2006 18.01.2006 08.02.2006 01.01.2006 01.02.2006 09.01.2006 09.02.2006 09.01.2006 08.02.2006 12.01.2006 09.02.2006 11.01.2006 06.02.2006 The problem is, dafediff function works to find the number of the difference of days in between these dates.. however it uses a standard format: "YYYY-MM-DD" .. meaning date format must be in this particular format for this function to work in visual basic 6.0 Is there anyway I can use maybe sql query to do this problem? Rather than splitting and joining, I have about 30,000 date values in each file.. for about 24 files.. which will take alot of CPU memory and be slow.. All help is appreciated. |
|
#2
|
|||
|
|||
|
You could use the cdate() function to convert your string dates to date datatypes before passing to datediff.
__________________
====== Doug G ====== "Hide, hide witch! The good folk come to burn thee. Their keen enjoyment hid behind their gothic mask of duty." -Mark Clifton |
|
#3
|
||||
|
||||
|
Have you tried Replace function? Replace the (.) with (-) and test datediff? I don't know if it will work i don't have VB here to test.
Anyway, where is the data located? In the database or in a file? |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > Visual Basic Programming > Date format and datediff problem.. |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|