Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 345
  • Last Modified:

Min Date?

C# / .NET  /  AngularJS  /  JSON:


If I am passing a DateTime value as a parameter ... how do I get "MinDate" such that SQL Server (T-SQL) will consume it and JSON will translate it?

In other words, this is what I have been passing:

 ticketList = _esnService.ECIDHDTicketList(userProfile.VendorID,
                    userProfile.PublicAPICompany,
                    "",
                    userProfile.PublicAPIUsername,
                    userProfile.PublicAPIPassword,
                    "",
                    "BB00",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    "",
                    DateTime.Parse("2009-03-13 22:16:00"),
                    "",
                    true);

Open in new window




Notice this param:

                    DateTime.Parse("2009-03-13 22:16:00"),


I want to do the same thing, but using something more generic, like "MinDate( )" or something or other.  I want to stop hard-coding the string that represents the datetime value.
0
Tom Knowlton
Asked:
Tom Knowlton
4 Solutions
 
Ioannis ParaskevopoulosCommented:
Have you tried DateTime.Now

It will always fetch the current date and time at the time you request it. Both SQL and javascript should be able to handle it.
0
 
David Johnson, CD, MVPOwnerCommented:
date mindate = datetime.now.adddays(-365)   ' a year ago
0
 
Jacques Bourgeois (James Burger)PresidentCommented:
If MinDate is always the same date, then simply write a method^

		public DateTime MinDate()
		{
			return (DateTime.Parse("2009-03-13 22:16:00"));
		}

Open in new window


 and call it:

      ...
      "",
      MinDate(),
      "",
     true);
0
 
Mihai StancescuSoftware Engineer Commented:
Hi,

If you really want min date for SQL Server you can use: SqlDateTime.MinValue (in System.Data.dll).
Notice that SQL MinDate is different than C# min date. Sql Min Date is 1st January 1753.

Hope this helps!

Regards,
Mishu
0
 
Tom KnowltonWeb developerAuthor Commented:
thx
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now