구체적으로 뭐가 어렵나요??
이런걸 원하시는 건지 모르겠는데요!!!
select count(seq) from table
where SUBSTRING(visitdt, 1, 4) = '년도'
and SUBSTRING(visitdt, 5, 2) = '월'
and SUBSTRING(visitdt, 7,2) = '일'
and SUBSTRING(visitdt, 9, 2) = '시간'
and SUBSTRING(visitdt, 11, 2) = '분'
and SUBSTRING(visitdt, 13, 2) = '초'
visitdt 의 자료형이 datetime이었다면
//====================================================// DATEPART (MSSQL) SELECT GETDATE(), DATEPART(year, GETDATE()) AS '년도', DATEPART(quarter, GETDATE()) AS '분기(1-4)', DATEPART(month, GETDATE()) AS '달', DATEPART(dayofyear, GETDATE()) AS '일수(1-366)', DATEPART(day, GETDATE()) AS '일자', DATEPART(week, GETDATE()) AS '주수(1-53)', DATEPART(weekday, GETDATE()) AS '요일', DATEPART(hour, GETDATE()) AS '시간', DATEPART(minute, GETDATE()) AS '분', DATEPART(second, GETDATE()) AS '초', DATEPART(millisecond, GETDATE()) AS '밀리초' //---------------------------------------------------// 결과 GETDATE : 2005-08-05 17:54:14.013 년도 : 2005 분기 : 3 달 : 8 일수 : 217 일자 : 5 주소(1-53): 32 요일 : 6 시간 : 17 분 : 54 초 : 14 밀리초 : 13 //====================================================// DATEPART (MSSQL)
//====================================================// DATENAME (MSSQL) SELECT GETDATE(), DATENAME(year, GETDATE()) AS '년도', DATENAME(quarter, GETDATE()) AS '분기(1-4)', DATENAME(month, GETDATE()) AS '달', DATENAME(dayofyear, GETDATE()) AS '일수(1-366)', CASE LEN(DATENAME(day, GETDATE())) WHEN 1 THEN '0' + DATENAME(day, GETDATE()) ELSE DATENAME(day, GETDATE()) END AS '일자', DATENAME(week, GETDATE()) AS '주수(1-53)', DATENAME(weekday, GETDATE()) AS '요일', CASE LEN(DATENAME(hour, GETDATE())) WHEN 1 THEN '0' + DATENAME(hour, GETDATE()) ELSE DATENAME(hour, GETDATE()) END AS '시간', CASE LEN(DATENAME(minute, GETDATE())) WHEN 1 THEN '0' + DATENAME(minute, GETDATE()) ELSE DATENAME(minute, GETDATE()) END AS '분', CASE LEN(DATENAME(second, GETDATE())) WHEN 1 THEN '0' + DATENAME(second, GETDATE()) ELSE DATENAME(second, GETDATE()) END AS '초', DATENAME(millisecond, GETDATE()) AS '밀리초' //---------------------------------------------------// 결과 GETDATE : 2005-08-05 17:54:14.013 년도 : 2005 분기 : 3 달 : 08 일수 : 217 일자 : 05 주소(1-53): 32 요일 : 금요일 시간 : 17 분 : 54 초 : 14 밀리초 : 13 //====================================================// DATENAME (MSSQL)
이럲게 사용할 수 있습니다.