Click here to Skip to main content
15,881,248 members
Home / Discussions / Database
   

Database

 
AnswerRe: BLOB or external storage... Pin
Richard Deeming27-Jan-15 1:50
mveRichard Deeming27-Jan-15 1:50 
GeneralRe: BLOB or external storage... Pin
Jörgen Andersson27-Jan-15 3:06
professionalJörgen Andersson27-Jan-15 3:06 
AnswerRe: BLOB or external storage... Pin
deepakdynamite28-Jan-15 0:30
deepakdynamite28-Jan-15 0:30 
QuestionDatediff function Pin
Ambertje26-Jan-15 2:18
Ambertje26-Jan-15 2:18 
AnswerRe: Datediff function Pin
Chris Quinn26-Jan-15 2:25
Chris Quinn26-Jan-15 2:25 
GeneralRe: Datediff function Pin
Ambertje26-Jan-15 2:34
Ambertje26-Jan-15 2:34 
GeneralRe: Datediff function Pin
Chris Quinn26-Jan-15 2:42
Chris Quinn26-Jan-15 2:42 
GeneralRe: Datediff function Pin
Ambertje26-Jan-15 3:12
Ambertje26-Jan-15 3:12 
Hi Chris,

I need my dates as string because I'm working with a Data warehouse DB.

SQL
, CAST(Replace(convert(date, [START_DATE], 101), '-', '') as numeric(8,0))                              AS [START_DATE]

, CAST(dbo.LPAD(dbo.CONVERT_TIME_TO_NUMERIC(SUBSTRING(dbo.arKD.START_TIME,1,8)), 6, 0)AS nvarchar(6))   AS START_TIME

, CAST(Replace(convert(date, END_DATE, 101), '-', '') as numeric(8,0))                                  AS END_DATE

, CAST(dbo.LPAD(dbo.CONVERT_TIME_TO_NUMERIC(SUBSTRING(dbo.arKD.END_TIME,1,8)), 6, 0)AS nvarchar(6))     AS END_TIME

--DATEDIFF(interval, Starting_date datetime, ending_date datetime)
,Datediff(SECOND,
     convert(datetime, [START_DATE] + ' ' + [START_TIME]),
     convert(datetime, [END_DATE] + ' ' + [END_TIME]))                                                  AS M_Time_Worked


This is actual code where I Cast all dates to nvarchar.

So how can I change this code in a way that I can set the Start_Date (when empty) to the value of End_Date and Start_Time to the value of End_Time when empty?

I'm not an experienced developer, I'm still learning and hope you can learn me something new.

Kind regards,
Ambertje
GeneralRe: Datediff function Pin
Chris Quinn26-Jan-15 3:18
Chris Quinn26-Jan-15 3:18 
GeneralRe: Datediff function Pin
Ambertje26-Jan-15 3:26
Ambertje26-Jan-15 3:26 
GeneralRe: Datediff function Pin
Jörgen Andersson26-Jan-15 21:17
professionalJörgen Andersson26-Jan-15 21:17 
AnswerRe: Datediff function Pin
PIEBALDconsult26-Jan-15 5:57
mvePIEBALDconsult26-Jan-15 5:57 
GeneralRe: Datediff function Pin
Ambertje26-Jan-15 22:21
Ambertje26-Jan-15 22:21 
GeneralRe: Datediff function Pin
Corporal Agarn27-Jan-15 3:46
professionalCorporal Agarn27-Jan-15 3:46 
GeneralRe: Datediff function Pin
Ambertje3-Feb-15 5:36
Ambertje3-Feb-15 5:36 
GeneralRe: Datediff function Pin
Ambertje27-Jan-15 0:03
Ambertje27-Jan-15 0:03 
QuestionAccess query convert to MSSQL query Pin
Ray Raymos24-Jan-15 9:12
Ray Raymos24-Jan-15 9:12 
AnswerRe: Access query convert to MSSQL query Pin
Mycroft Holmes24-Jan-15 12:49
professionalMycroft Holmes24-Jan-15 12:49 
QuestionERD fee management system keep the record of whole year Pin
Haidar ali23-Jan-15 17:04
Haidar ali23-Jan-15 17:04 
AnswerRe: ERD fee management system keep the record of whole year Pin
Richard MacCutchan23-Jan-15 22:45
mveRichard MacCutchan23-Jan-15 22:45 
GeneralRe: ERD fee management system keep the record of whole year Pin
Mycroft Holmes23-Jan-15 23:09
professionalMycroft Holmes23-Jan-15 23:09 
GeneralRe: ERD fee management system keep the record of whole year Pin
Richard MacCutchan23-Jan-15 23:20
mveRichard MacCutchan23-Jan-15 23:20 
GeneralRe: ERD fee management system keep the record of whole year Pin
Haidar ali24-Jan-15 7:41
Haidar ali24-Jan-15 7:41 
GeneralRe: ERD fee management system keep the record of whole year Pin
Haidar ali24-Jan-15 7:42
Haidar ali24-Jan-15 7:42 
GeneralRe: ERD fee management system keep the record of whole year Pin
Richard MacCutchan24-Jan-15 7:47
mveRichard MacCutchan24-Jan-15 7:47 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.