Showing posts with label care. Show all posts
Showing posts with label care. Show all posts

Wednesday, March 28, 2012

Subtracting from a Date

Hello,

In .NET code, I need to subtract a month from the current date; is there something in the framework that does this; there is some care that is needed to do this, especially with 28-day and 30-day months, so I was wondering if there was something built-in.

Thanks.

If I understand you question right you could do this:

DateTime dtTemp = DateTime.Now;

int Month = dtTemp.Month;

Cheers

Al


Dim dAs DateTime

d = DateTime.Now

d = d.AddMonths(-1)


If you write VB.NET try the link below for DateDiff function a clone of the T-SQL version. Hope this helps.

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vblr7/html/vafctdatediff.asp


Hello,

Try it:

Dim LastMonth As Date = DateAdd(DateInterval.Month, -1, #3/27/2006#)

You'll found this function under following namespace:
Microsoft.VisualBasic

An this will solve your problem related to 28-days/30-days. Functions takes care of this.

Regards

Kuldeep Deokule

Tuesday, March 13, 2012

Switch page to SSL Programatically?

Howdy,
I'm trying to have select pages always be secure and others I don't care.
I'm using
If Request.ServerVariables("SERVER_PORT") = 80 Then
Dim strSecureURL
strSecureURL = "https://"
strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")
strSecureURL = strSecureURL & Request.ServerVariables("URL")
Response.Redirect(strSecureURL)
End If
This works, but is there a better way for .net 2.0?
Thanks,
Merry Christmas
David LozziInstead of testing for the server port variable, test for the HTTPS
variable. It will return ON if it's a secure connection or OFF it is isn't.
This would avoid any issues where the server or ssl certificate is running
on a port other than 80.
Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199...2006
"David Lozzi" <dlozzi@.nospam.nospam> wrote in message
news:%23VNNyktGHHA.4112@.TK2MSFTNGP04.phx.gbl...
> Howdy,
> I'm trying to have select pages always be secure and others I don't care.
> I'm using
> If Request.ServerVariables("SERVER_PORT") = 80 Then
> Dim strSecureURL
> strSecureURL = "https://"
> strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")
> strSecureURL = strSecureURL & Request.ServerVariables("URL")
> Response.Redirect(strSecureURL)
> End If
>
> This works, but is there a better way for .net 2.0?
>
> Thanks,
> Merry Christmas
> David Lozzi
>
"David Lozzi" <dlozzi@.nospam.nospam> wrote in message
news:%23VNNyktGHHA.4112@.TK2MSFTNGP04.phx.gbl...

> This works, but is there a better way for .net 2.0?
http://www.codeproject.com/aspnet/W...&select=1697847

Switch page to SSL Programatically?

Howdy,

I'm trying to have select pages always be secure and others I don't care.
I'm using

If Request.ServerVariables("SERVER_PORT") = 80 Then

Dim strSecureURL

strSecureURL = "https://"

strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")

strSecureURL = strSecureURL & Request.ServerVariables("URL")

Response.Redirect(strSecureURL)

End If

This works, but is there a better way for .net 2.0?

Thanks,

Merry Christmas

David LozziInstead of testing for the server port variable, test for the HTTPS
variable. It will return ON if it's a secure connection or OFF it is isn't.
This would avoid any issues where the server or ssl certificate is running
on a port other than 80.

--

Hope this helps,
Mark Fitzpatrick
Former Microsoft FrontPage MVP 199?-2006

"David Lozzi" <dlozzi@.nospam.nospamwrote in message
news:%23VNNyktGHHA.4112@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

Howdy,
>
I'm trying to have select pages always be secure and others I don't care.
I'm using
>
If Request.ServerVariables("SERVER_PORT") = 80 Then
>
Dim strSecureURL
>
strSecureURL = "https://"
>
strSecureURL = strSecureURL & Request.ServerVariables("SERVER_NAME")
>
strSecureURL = strSecureURL & Request.ServerVariables("URL")
>
Response.Redirect(strSecureURL)
>
End If
>
>
>
This works, but is there a better way for .net 2.0?
>
>
>
Thanks,
>
Merry Christmas
>
David Lozzi
>
>


"David Lozzi" <dlozzi@.nospam.nospamwrote in message
news:%23VNNyktGHHA.4112@.TK2MSFTNGP04.phx.gbl...

Quote:

Originally Posted by

This works, but is there a better way for .net 2.0?


http://www.codeproject.com/aspnet/W...&select=1697847