SQLServer epoch time null date - sql-server

I have a date column in the table which gets values from csv file. Right now if the date value is null, 1900/01/01 is getting inserted. How can I change it to empty string?
Thanks

In you CSV file select the column and change its type to simple text and then try to import the data.

Related

Calculated Date column for csv import SSMS

I am trying to bulk import a data csv file into a database table. One of the columns in the csv file is a Date column. Unfortunately, the dates in this column are in different formats, namely, some are in YYYYMMDD and some are YYYY/MM/DD. They are also stored as type string in the csv.
I am trying to set the Date column in the table to be a calculated column, such that, when I import the csv file, the dates in the date column in the csv, are converted into a consistent format, i.e. YYYYMMDD.
Is this possible?
How can I set the calculated table column to do this?
I have tried the below, but am getting an error, as I cannot reference the same column in a calculated column (doh!).
[Date] AS TRY_CONVERT(DATE, [Date])

Data conversion from Varchar to Date SQL server

I have a SourceTable which contains two columns First_Sale_Date and Last_Sale_Date and both are of data type varchar(10). The First_Sale_Date column contains date(mm/dd/yyyy format) and the Last_Sale_Date contain nothing.
I need to load SourceTable data to Table 2 with same column(columns First_Sale_Date and Last_Sale_Date) but in Table2 both columns are of date data type. the problem is when i load the data to Table2 from SourceTable, the first column is loaded as converted date format but in the second column values shown as NULL . I want the Table2 to be empty if there are no records in SourceTable
Please help me to fix this issue. Thank you for your time and help

sql server date stored in table comparing with the system date

really struggling to convert the below date format 10.11.2013 in the format
of the system date.
I have a request to compare column data with the system date.
In the column the date is storing as DD.MM.YYYY
Or we need to convert system date (getdate()) to the date values stored in the database table.
Thanks in Advance
Regards,
Dev
try this:
convert system date (getdate()) to the date values stored in the
database table.
Gives formats as DD.MM.YYYY
select CONVERT( CHAR(10),GETDATE(),104) -- outputs 11.09.2014
with Your Column
select CONVERT( CHAR(10),MyColumn,104)

date between query issue in sqlite3

In my data base , i was stored one student data in the following date format is 07-03-2013(dd-mm-yyyy). For example the start date greater than the end date ,no row return in the results.
For Ex.
select student_name from general_details where join_date between '11-02-2013' and '08-03-2013'
it returns 0
if start date less than the end date
select student_name from general_details where join_date between '01-02-2013' and '08-03-2013'
it returns row value 1;
Please suggest ,thanks in advance
The dates are compared alphabetically and not as datetime stamps.
If you can influence how the dates are stored, use a format such as ISO-8601 yyyy-MM-dd or unix epoc timestamps to make the comparisons work.
If you cannot influence the data, you can convert the values in SQL by picking up the components with substr() and concatenating together with ||, like this:
substr(join_date,7,4) || substr(join_date,4,2) || substr(join_date,1,2)

T-SQL - changing datetime to date data type?

I have a column BirthDate in a table that is using the datetime data type. Currently, the values resemble the format 1987-12-30 00:00:00.000.
I would like to update all the rows of this table, changing them to the following format with the date data type: 1987-12-30
I can run a SELECT...
SELECT CONVERT(date, BirthDate) FROM CUSTOMERLIST
But this is only affecting the display. I would like for it to update the entire column and also change the data type of that attribute as well. Any assistance would be greatly appreciated!
You will need to ALTER the table:
ALTER TABLE CUSTOMERLIST ALTER COLUMN BirthDate date not null
See Sql Fiddle with demo

Resources