-
[RESOLVED] formula help!
Hi I need an urgent help for you…
I need to change the display for a field returned from an old XML and put it on to a new .XML file.
Currently I have the following to block the date to be displayed, “-“ is displayed for each field as a result.
Set oDoc = New DOMDocument
oDoc.loadXML xmlstring
Set nodList = oDoc.selectNodes("//date")
For Each nod In nodList
nod.Text = "-"
Next
How I need to work out now is instead of displaying “-“, I need them to be more details, compared to the current date. For example, if the date is “01/01/08”(this is the format in the old .xml), it will show “6 months ago”, and if the date is “20/01/07” it will show “18 months ago”. I can’t figure out a formula to compare months… and how can I get the value of <date> from the old .XML?? can someone please help.!! Thanks!!!
-
Re: formula help!
I think you need to use DateDiff function - for sample code search forum.
-
Re: formula help!
problem solved!
Code:
b = nod.Text
c = DateDiff("m", b, a)
If c < 24 Then
nod.Text = c & " months ago"
Else
c = c / 12
d = c Mod 12
nod.Text = c &"years and" & d & " months ago"
End If
Thanks for your help!:)