Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
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  
Old May 5th, 2008, 08:22 PM
awyeah awyeah is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 15 awyeah User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 h 31 m 34 sec
Reputation Power: 0
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.

Reply With Quote
  #2  
Old May 5th, 2008, 11:27 PM
Doug G Doug G is offline
Grumpier Old Moderator
Dev Shed God 12th Plane (10500 - 10999 posts)
 
Join Date: Jun 2003
Posts: 10,687 Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level)Doug G User rank is Brigadier General (60000 - 70000 Reputation Level) 
Time spent in forums: 4 Weeks 1 Day 16 h 39 m 15 sec
Reputation Power: 688
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

Reply With Quote
  #3  
Old May 6th, 2008, 11:35 PM
zynder's Avatar
zynder zynder is offline
Not much of a contributor
Dev Shed Novice (500 - 999 posts)
 
Join Date: Aug 2006
Location: Hidden
Posts: 782 zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)zynder User rank is Brigadier General (60000 - 70000 Reputation Level)  Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1Folding Points: 133931 Folding Title: Super Ultimate Folder - Level 1
Time spent in forums: 1 Week 2 Days 19 h 13 m 58 sec
Reputation Power: 610
Send a message via Yahoo to zynder
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?

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Date format and datediff problem..


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 6 hosted by Hostway