1

I am in trouble. I have an requirement where I need to sort date values using VB script but I couldn't find the way how to do it.

My Sample code is below:

Option Explicit

Dim Date1,Date2

Date1=#9/14/2012  1:15:20 AM#
Date2=#9/15/2012  2:36:49 PM#

If Date1>Date2 Then

 MsgBox("Hi")

Else

 MsgBox("Hello")

End If

But the above code is not producing correct message when I ran it. Can any one help me here?

Aziz Shaikh
  • 16,245
  • 11
  • 62
  • 79
Arup Rakshit
  • 116,827
  • 30
  • 260
  • 317
  • 1
    Bonus tip: If you are designing a function that *sorts* dates, consider using an `ArrayList` instead of building your own. Lists have a native `Sort` method that can sort all primitive data types. – AutomatedChaos Dec 05 '12 at 12:26
  • @AutomatedChaos -- can you help me here in my below post? http://stackoverflow.com/questions/13798858/row-data-partition-empty-column-values-in-a-row-in-one-side-and-non-empties-ar#comment18983534_13798858 – Arup Rakshit Dec 10 '12 at 12:39

1 Answers1

0

I can't see any problems with:

>> Date1=#9/14/2012  1:15:20 AM#
>> WScript.Echo Date1
>> Date2=#9/15/2012  2:36:49 PM#
>> WScript.Echo Date2
>> WScript.Echo CStr(Date1 > Date2)
>> WScript.Echo DateDiff("s", Date2, Date1)
>> WScript.Echo DateDiff("h", Date2, Date1)
>> WScript.Echo DateDiff("d", Date2, Date1)
>>
14.09.2012 01:15:20   <-- german locale
15.09.2012 14:36:49
False
-134489
-37
-1
Ekkehard.Horner
  • 38,498
  • 2
  • 45
  • 96
  • @Ekkrhard.Horner Can you help me in the below post ? http://stackoverflow.com/questions/13798858/row-data-partition-empty-column-values-in-a-row-in-one-side-and-non-empties-ar#comment18983534_13798858 – Arup Rakshit Dec 10 '12 at 12:38