Min Date?

Posted on 2014-10-31
Last Modified: 2014-11-03
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,
                    DateTime.Parse("2009-03-13 22:16:00"),

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.
Question by:knowlton
LVL 23

Assisted Solution

by:Ioannis Paraskevopoulos
Ioannis Paraskevopoulos earned 25 total points
ID: 40416945
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.
LVL 78

Assisted Solution

by:David Johnson, CD, MVP
David Johnson, CD, MVP earned 25 total points
ID: 40417182
date mindate =   ' a year ago
LVL 40

Assisted Solution

by:Jacques Bourgeois (James Burger)
Jacques Bourgeois (James Burger) earned 50 total points
ID: 40417187
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:

LVL 11

Accepted Solution

Mihai Stancescu earned 400 total points
ID: 40417926

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!


Author Closing Comment

ID: 40419695

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction This article shows how to use the open source plupload control to upload multiple images. The images are resized on the client side before uploading and the upload is done in chunks. Background I had to provide a way for user…
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

920 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now