Past date calculation - Programmers Heaven

#### Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

# Past date calculation

Posts: 24Member
Hi, please help, can anyone share a good subroutine to calculate a past date from a date variable? say if I want to find out what the date was 25 months ago or 38 days ago from today. Thanks.

• Posts: 1Member
: Hi, please help, can anyone share a good subroutine to calculate a past date from a date variable? say if I want to find out what the date was 25 months ago or 38 days ago from today. Thanks.
:
:
You can use Datediff function for this situation.In reality the method you demand depends on your requirements...
• Posts: 1,134Member
: Hi, please help, can anyone share a good subroutine to calculate a past date from a date variable? say if I want to find out what the date was 25 months ago or 38 days ago from today. Thanks.
:
:
The .NET date object has built in functions ...

[code]
' Get Current Date
Dim dt As Date = Date.Now.Date

' Subtract 25 Months

' Subtract 38 Days
[/code]

• Posts: 24Member
: : Hi, please help, can anyone share a good subroutine to calculate a past date from a date variable? say if I want to find out what the date was 25 months ago or 38 days ago from today. Thanks.
: :
: :
: You can use Datediff function for this situation.In reality the method you demand depends on your requirements...
:
• Posts: 24Member
: : Hi, please help, can anyone share a good subroutine to calculate a past date from a date variable? say if I want to find out what the date was 25 months ago or 38 days ago from today. Thanks.
: :
: :
: The .NET date object has built in functions ...
:
: [code]
: ' Get Current Date
: Dim dt As Date = Date.Now.Date
:
: ' Subtract 25 Months
:
: ' Subtract 38 Days
: [/code]
:
:
:
Hi Iwilld0it, you know what? you really have made my day, thank you very much, that's exactly what I was looking for and it works. Just how did you figure that out?
• Posts: 1,134Member
: : : Hi, please help, can anyone share a good subroutine to calculate a past date from a date variable? say if I want to find out what the date was 25 months ago or 38 days ago from today. Thanks.
: : :
: : :
: : The .NET date object has built in functions ...
: :
: : [code]
: : ' Get Current Date
: : Dim dt As Date = Date.Now.Date
: :
: : ' Subtract 25 Months